package com.lagou.homework;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class HomeWorkReducer extends Reducer<IntWritable, NullWritable, IntWritable,IntWritable> {
    IntWritable pos = new IntWritable(1);

    @Override
    protected void reduce(IntWritable key, Iterable<NullWritable> values, Context context) throws IOException, InterruptedException {
        for (NullWritable value : values) {
            context.write(pos,key);
            pos = new IntWritable(pos.get() + 1);
        }
    }
}
